<?php
include 'head.php';

$curr_page = 1;//当前页
$pages = 14;//每页多少条
$newsCount = 0;//共多少条新闻
$pageCount = 0;//多少页
$start_news = 0;//从第几条开始取
$end_news = 0;//取到第几条

$sql = "select count(*) as newsCount from  en_news where flag =1";
$result =mysql_query($sql);
$row = mysql_fetch_array($result);

$newsCount = $row["newsCount"];

if($newsCount<=$pages)
{
	$pageCount =1;
}else
{
	$pageCount = floor($newsCount%$pages>0?$newsCount/$pages+1:$newsCount/$pages);
}

//检查当前页是否合法
if(isset($_GET['curr_page'])&&is_numeric($_GET['curr_page']))
{
	if($_GET['curr_page']<=$pageCount&&$_GET['curr_page']>0)
	{
		$curr_page = $_GET['curr_page'];
	}
}

$start_news = ($curr_page-1)*6+1;
$end_news = ($curr_page-1)*6 +$pages;
?>
<link href="1.css" rel="stylesheet" type="text/css">
<style>
	#nrbottomy a{
		text-decoration:none;
		
	}
	#nrbottomy a:link{
		color:blue;
		
	}
#nrbottomy a:visited{
		color:blue;
		
	}
	.news_a{
		text-decoration:none;
		color:black;
	}
	.news_a:HOVER {
		text-decoration:underline;
		color:red;
	}
	
</style>
<div id="ym">

	
     <div id="main" style="background:#FFFFFF; width:960px; height:633px;">
	     
		 <div id="dh" style="background:none;width:960px; height:633px;">
		 
	       
			 
			 <div class="gg1">
			 
			 		<div class="gddh">Home</div>
					<div class="gddh1"><a href="#" style="text-decoration:none;">News</a><span style="width:4px; height:7px; margin-left:84px;"><img src="images/xw_lbarxl.png"/></span></div>
					
				
			 </div>
			 <div class="nrdh"><h1 style="text-indent:16px; margin-top:11px;">News</h1></div>
			 
			 <div class="nrk">
			    <div style="height:450px;">
			  <?php
			  		$sql = "select id,path,title,content,dates,istop from en_news where flag =1 limit ".($start_news-1).",".$pages;
			  		$result = mysql_query($sql);
			  		while($row = mysql_fetch_array($result))
			  		{
			  ?>
			  	 <div id="news">
				
				 	<h2 style="color:#393939"><span style="margin-right:4px;"><img src="images/xw_bd.jpg"/></span><a class="news_a" href="news_info.php?id=<?php echo $row['id'];?>"><?php echo $row["title"];?></a></h2>
				
					<h2 style="float:right; color:#8e8e8e"><?php echo $row["dates"]?></h2>
					
				</div>
			  <?php
			  		}
			  ?>
			    </div>
				<div>
					<div id="nrbottomz">
					
						<h3><?php echo $start_news;?>-<?php echo $end_news;?></h3>
						<h3 style=" width:110px; height:12px; float:right; margin-top:-14px;"><?php echo $curr_page;?>/<?php echo $pageCount;?></h3>
						
					</div>
					
					<div id="nrbottomy" >
					
						<h4><a <?php if($curr_page!=1){echo "href='news.php?curr_page=1'";}?>>First</a></h4>
						
						<h5><a  <?php if($curr_page>1){echo "href='news.php?curr_page=".($curr_page-1)."'";}?>>Prev</a></h5>
							
						<h5><a <?php if($curr_page<$pageCount){echo "href='news.php?curr_page=".($curr_page+1)."'";}?>>Next</a></h5>
							
						<h4><a <?php if($curr_page!=$pageCount){echo "href='news.php?curr_page=".($pageCount)."'";}?>>Last</a></h4>
						
							
					</div>
				</div>	
					 
				

			</div>
			
			 <div class="gg2" style="margin-left:16px; background:none;">
			 <?php
			   $sql = "select * from en_ad where id = 22";
			   $ret = mysql_query($sql);
			   $rcd = mysql_fetch_array($ret);
			 ?>
			 <a href="<?php echo $rcd['link']?>" target='_blank'><img src="<?php echo $rcd['pic_path'];?>" /></a>
			 </div>
			 
			 
			 
	     </div>
		 
	 </div>
	 
	 
	
	 
	  <?php include 'bottom.php';?>
</div>